package org.example.syn;

import java.util.HashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;

/**
 * @author Yyming
 * @version 10.0
 * Created by Yyming on 2020/10/29
 */
public class FutureTaskTest {
    private static final HashMap<String, Object> cache = new HashMap<>();


    public Object get(String key) throws InterruptedException {
        Object o = cache.get(key);
        if (o != null) {
            o = this.compute(key);
            cache.put(key, o);
        }
        return cache;
    }


    private Object compute(String key) throws InterruptedException {
        TimeUnit.SECONDS.sleep(1);
        return new Object();
    }

    public static void main(String[] args) {
        FutureTaskTest futureTaskTest = new FutureTaskTest();

    }


}
